package com.md.api.service.impl;

import com.md.api.common.utils.TokenUtil;
import com.md.api.dao.AdvertisementInfoMapper;
import com.md.api.dao.ShoppingCartMapper;
import com.md.api.entity.AdvertisementInfo;
import com.md.api.entity.HttpResult;
import com.md.api.entity.MyShopCart;
import com.md.api.entity.dto.ComposeQueryDto;
import com.md.api.entity.util.Page;
import com.md.api.service.AdvertService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author liujie
 * @ClassName ProductServiceImpl
 **/

@Slf4j
@Service
public class AdvertServiceImpl implements AdvertService {



    @Resource
    TokenUtil tokenUtil;
    @Resource
    AdvertisementInfoMapper advertisementInfoMapper;



    @Override
    public HttpResult getByType(ComposeQueryDto qto) {
        List<AdvertisementInfo> advertList = advertisementInfoMapper.advertList(qto.getAdType());
        return new HttpResult(advertList);
    }

    @Override
    public HttpResult add(AdvertisementInfo advertisementInfo) {
        advertisementInfoMapper.insert(advertisementInfo);
        return HttpResult.OK;
    }

    @Override
    public HttpResult update(AdvertisementInfo advertisementInfo) {
        advertisementInfoMapper.update(advertisementInfo);
        return HttpResult.OK;
    }

    @Override
    public HttpResult delete(AdvertisementInfo advertisementInfo) {
        advertisementInfoMapper.delete(advertisementInfo.getId());
        return HttpResult.OK;
    }
}
